<?php // $this->load->view('layouts/_flash'); 
if(!empty($levels)){
$roomLevelAttrib[] ='choose level';
foreach($levels as $level){
	$roomLevelAttrib[$level->level_id] = strtoupper($level->level_code).' - '.$level->level_desc;
}
}else{
	$system_message = '<div class="notice">Please Add Levels Before adding subjects</div>';
	$roomLevelAttrib[''] = 'No levels set';
}
?>
<div class="row">
	<fieldset style="padding:5px;">
		<legend>Search Subject</legend>
		<form action="<?=site_url();?>admin/subjects" method="POST">
		<div class="input-block">
			<label>Subject Name:</label>
			<input type="text" name="search_strings[subj_desc]">
		</div>
		<div class="input-block">
		  <?php
			  echo form_label('Grade Level :', 'grade_level_id');
			  echo form_dropdown('search_strings[grade_level_id]', $roomLevelAttrib, set_value('grade_level_id'));	
		  ?>
		</div>
		<div class="input-block">
			<input type="submit" class="btn btn-small btn-success" name="search" value="search">
			<a href="<?php echo site_url('admin/add_subject'); ?>" class="btn btn-small btn-primary add">Add Subject</a>
		</div>
		</form>
	</fieldset>
<?if(isset($system_message))echo $system_message;?>

	<?if(!empty($subjects)):?>
	<fieldset>
			<legend>Subjects</legend>
	<table class="data-table">
		<thead class="tabular-head">
		<tr>
			<th>Subject ID</th>
			<th>Subject Code</th>
			<th>Subject Name</th>
			<th>Units</th>
			<th>Grade Level</th>
			<th>Edit Subject</th>
			<th>Activate/Deactivate</th>
		</tr>
		</thead>
		<tbody class="tabular">
		<?foreach($subjects as $subject):?>
			<tr>
				<td><?=$subject->subj_uniq_id;?></td>
				<td><?=$subject->subj_code;?></td>
				<td><?=$subject->subj_desc;?></td>
				<td><?=$subject->subj_units;?></td>
				<td><?=$subject->level_desc;?></td>
				<td><a href="<?php echo site_url('admin/edit_subject/'.$subject->subj_id)?>" class="btn btn-small btn-primary edt">Update</a></td>
				<td>
				<?php if($subject->subj_stat == 'active'):?>
				  <a href="<?php echo site_url('admin/subjects/deactivate/'.$subject->subj_id)?>" class="btn btn-small btn-primary confirm" title="Deactivate <?php echo $subject->subj_desc;?>">Deactivate
				<?php elseif($subject->subj_stat == 'inactive'): ?>
				  <a href="<?php echo site_url('admin/subjects/activate/'.$subject->subj_id)?>" class="btn btn-small btn-primary confirm" title="Activate <?php echo $subject->subj_desc;?>">Activate
				</td>
				<?php endif; ?>
			</tr>
		<?endforeach;?>
		</tbody>
		</table>
		</fieldset>
	<?else:?>
		<fieldset>
			<legend>Warning</legend>
			<div class="notice"> No data avaialable</div>
		</fieldset>
	<?endif;?>
<?=$links;?>
</div>